{% include 'common/head.html' %}
<script type="text/javascript">
	// reply a reply
	function replyOne(username){
	    replyContent = $("#reply_content");
		oldContent = replyContent.val();
		prefix = "@" + username + " ";
		newContent = ''
		if(oldContent.length > 0){
		    if (oldContent != prefix) {
		        newContent = prefix + oldContent;
		    }
		} else {
		    newContent = prefix
		}
		replyContent.focus();
		replyContent.val(newContent);
	}
</script>
<body>
    {% include 'common/top.html' %}
    <div id="Wrapper">
    <div id="Main">
        <div id="Sidebar">
        </div>
        <div id="Rightbar">
            {% include 'rightbar/user.html' %}
            <div class="sep20"></div>
            {% if node.sidebar %}
            <div class="box"><div class="inner">{{ node.sidebar }}</div></div>
            <div class="sep20"></div>
            {% endif %}
            {% if topic.node.sidebar_ads %}
            <div class="box"><div class="inner">{{ topic.node.sidebar_ads }}</div></div>
            {% else %}
            {% include 'rightbar/ads.html' %}
            {% endif %}
            {% include 'rightbar/recent_nodes.html' %}
        </div>
        <div id="Content">
            <div class="box">
                {% if topic.has_content %}<div class="cell" style="min-height: 73px;">{% else %}<div class="inner" style="min-height: 73px;">{% endif %}
                    <div class="fr snow" style="padding-left: 10px; padding-bottom: 10px;"><a href="/member/{{ topic.member.username }}">{{ topic.member|avatar:"large" }}</a></div>
                    <span class="bigger"><a href="/">{{ site.title }}</a> {{ l10n.chevron }} <a href="/go/{{ node.name}}">{{ node.title|escape }}</a></span>
                    <h1>{{ topic.title|escape }}</h1>
                    <small class="fade">{% if site.use_topic_types %}{% if topic.type %}<span style="display: inline-block; background-color: {{ topic.type_color }}; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; color: #fff; padding: 0px 8px 0px 8px; font-size: 11px;">{{ topic.type }}</span> &nbsp;{% endif %}{% endif %}By <a href="/member/{{ topic.member.username }}" class="dark">{{ topic.created_by }}</a>{% if topic.source %} via {{ topic.source }}{% endif %} at {{ topic.created|timesince }} ago{% ifnotequal topic.hits 0 %}, {{ topic.hits }} hits{% endifnotequal %}{% ifequal member.level 0 %} &nbsp; <a href="#;" onclick="if (confirm('{{ l10n.sure_to_delete }} #{{ topic.num }} - {{ topic.title|escape }}')) { location = '/delete/topic/{{ topic.num }}?t={{ member.created_ts }}'; }" class="op">DELETE</a> <a href="/backstage/tidy/topic/{{ topic.num }}" class="op">TIDY</a>{% endifequal %}{% if can_move %} <a href="/backstage/move/topic/{{ topic.key }}" class="op">MOVE</a>{% endif %}{% if can_edit %} <a href="/edit/topic/{{ topic.num }}" class="op">EDIT</a>{% endif %}</small>
                </div>{% if topic.has_content %}
                <div class="inner">
                    <div class="content topic_content">{{ topic.content_rendered }}</div>
                </div>{% endif %}
                {% if member %}<div class="inner"><div class="fr" align="right">{% if topic.stars %}<span style="font-size: 10px; line-height: 10px; color: #99a;">已有 {{ topic.stars }} 人收藏此主题 &nbsp; </span>{% endif %}{% if favorited %}<a href="/unfavorite/topic/{{ topic.num }}?t={{ member.username_lower_md5 }}" class="op">取消收藏</a>{% else %}<a href="/favorite/topic/{{ topic.num }}?t={{ member.username_lower_md5 }}" class="op">加入收藏</a>{% endif %} &nbsp;<a href="#;" onclick="window.open('https://twitter.com/share?url=http://{{ site.domain }}/t/{{ topic.num }}&related=v2ex&hashtags={{ node.name }}&text={{ topic.title|escapejs }}', '_blank', 'width=550,height=370'); recordOutboundLink(this, 'Share', 'twitter.com');" class="op">Tweet</a> &nbsp;<a href="#;" onclick="window.open('http://shuo.douban.com/!service/share?href=http://{{ site.domain }}/t/{{ topic.num }}&name={{ site.title }}%20-%20{{ topic.title|escapejs }}', '_blank', 'width=550,height=370'); recordOutboundLink(this, 'Share', 'douban.com');" class="op">Douban</a> &nbsp;<a href="#;" onclick="window.open('http://service.weibo.com/share/share.php?url=http://{{ site.domain }}/t/{{ topic.num }}&title={{ site.title }}%20-%20{{ topic.title|escapejs }}', '_blank', 'width=550,height=370'); recordOutboundLink(this, 'Share', 'weibo.com');" class="op">Weibo</a></div> &nbsp; </div>{% endif %}
                {% ifequal topic.explicit 1 %}
                <div class="inner">
                    <script type="text/javascript"><!--
                    google_ad_client = "pub-9823529788289591";
                    /* 468x60, V2EX Explicit */
                    google_ad_slot = "8427270623";
                    google_ad_width = 468;
                    google_ad_height = 60;
                    //-->
                    </script>
                    <script type="text/javascript"
                    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                    </script>
                </div>
                {% endifequal %}
            </div>
            {% ifequal topic.replies 0 %}
            <div class="sep20"></div>
            <div class="glass" align="center"><div class="inner"><span class="white">{{ l10n.no_reply }}</span></div></div>
            {% else %}
            <div class="sep20"></div>
            <div class="box">
                <div class="cell"><div class="fr">{% if reply_reversed %}<a href="/t/{{ topic.num }}?r=0">{{ l10n.earlier_replies_first }}</a>{% else %}<a href="/t/{{ topic.num }}?r=1">{{ l10n.newer_replies_first }}</a>{% endif %} &nbsp;<span class="snow">|</span>&nbsp; {% if filter_mode %}<a href="/t/{{ topic.num }}?f=0">{{ l10n.show_all }}</a>{% else %}<a href="/t/{{ topic.num }}?f=1">{{ l10n.just_topic_creator }}</a>{% endif %}</div><span class="fade">{{ topic.replies }} {{ l10n.replies }} &nbsp;<span class="snow">|</span>&nbsp; {{ l10n.till }} {{ topic.last_touched|timezone:8|date:"Y-n-j G:i:s A" }}</span></div>
                <script type="text/javascript">
                    is_admin = {% if is_admin %}{{ is_admin }}{% else %}false{% endif %};
                    {% if member %}
                    member_id = {{ member.num }};
                    {% else %}
                    member_id = 0;
                    {% endif %}
                    replies_keys = new Array(); replies_ids = new Array(); replies_parents = new Array();
                </script>
                <div id="replies">
                {{ r }}
                </div>
                {% if member %}
                <script type="text/javascript">
                function a() {
                    blocked = [{{ blocked }}];
                    $("#replies").children('.reply').each( function(index) {
                        for (i in blocked) {
                            if ($(this).hasClass('from_' + blocked[i])) {
                                $(this).css('display', 'none');
                            }
                        }
                    });
                    i = 0;
                    $("#replies").children('.reply').each( function(index) {
                        i++;
                        if (is_admin) {
                            $(this).find("span.ops").html(' &nbsp; <a href="/backstage/tidy/reply/' + replies_ids[index] + '" class="op">TIDY</a> <a href="/edit/reply/' + replies_ids[index] + '" class="op">EDIT</a> <a href="#;" onclick="if (confirm(\'{{ l10n.sure_to_delete }} #' + i + '\')) { location.href = \'/backstage/remove/reply/' + replies_keys[index] + '?t={{ member.created_ts }}\'; }" class="op">DEL</a> &nbsp;<img src="/static/img/' + (replies_parents[index] ? 'empty.png' : 'dot_red.png') + '" align="absmiddle" />');
                        }
                    }
                    );
                }
                setTimeout("a()", 100);
                </script>
                {% endif %}
                {% if ps %}
                <div class="inner" align="center">
                    {% for p in ps %}{% ifequal p page_current %}<span class="page_current">{{ p }}</span>{% else %}<a href="/t/{{ topic.num }}?p={{ p }}" class="page_normal">{{ p }}</a>{% endifequal %}{% endfor %}
                </div>
                {% endif %}
            </div>
            {% endifequal %}
            {% if member %}
            <div class="sep20"></div>
            <script type="text/javascript">
            function v() {
                r = document.getElementById('reply_content');
                if (r.value.length == 0) {
                    e = document.getElementById('e');
                    e.innerHTML = "{{ l10n.reply_content_cannot_be_empty }}";
                    return false;
                }
            }
            
            function c() {
                e = document.getElementById('e');
                if (e.innerHTML.length > 0) {
                    e.innerHTML = '';
                }
            }
            </script>
            <div class="box"><form action="/t/{{ topic.num }}" method="post" onsubmit="return v()">
                <div class="cell">{% if errors %}
                <strong class="black">{{ reply_content_error_message }}</strong>
                {% else %}<div class="fr fade">⬆ <a href="#_top" class="dark">回到顶部</a></div>
                <span class="fade">{{ l10n.add_a_reply_now }}</span>
                {% endif %}
                </div>
                <div class="cell">
                    <textarea class="mll" name="content" id="reply_content" style="height: 200px;" onkeyup="c();"></textarea>
                    <div class="sep10"></div>
                    <div class="fr fade" id="e"></div>
                    <input type="submit" class="super normal button" value="{{ l10n.send }}" />
                </div></form>
                {% ifequal topic.explicit 1 %}
                <div class="inner">
                    <script type="text/javascript"><!--
                    google_ad_client = "pub-9823529788289591";
                    /* 468x60, V2EX Explicit */
                    google_ad_slot = "8427270623";
                    google_ad_width = 468;
                    google_ad_height = 60;
                    //-->
                    </script>
                    <script type="text/javascript"
                    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                    </script>
                </div>
                {% endifequal %}
                <div class="inner"><div class="fr" style="font-size: 12px; margin-left: 20px;"><a href="/">← {{ site.title }}</a></div>{{ l10n.no_pointless }}</div>
            </div>
            {% endif %}
        </div>
    <div class="c"></div>
    </div>
    </div>
    {% include 'common/bottom.html' %}
</body>
</html>